# Maintainer: Jonas Witschel <diabonas@archlinux.org>
# Contributor: Bruno Pagani <archange@archlinux.org>
pkgname=tpm2-tools
pkgver=5.3
pkgrel=2
pkgdesc='Trusted Platform Module 2.0 tools based on tpm2-tss'
arch=('loong64' 'x86_64')
url='https://github.com/tpm2-software/tpm2-tools'
license=('BSD')
depends=('curl' 'openssl' 'tpm2-tss' 'util-linux-libs' 'libtss2-esys.so' 'libtss2-fapi.so'
         'libtss2-mu.so' 'libtss2-rc.so' 'libtss2-sys.so' 'libtss2-tctildr.so')
checkdepends=('cmocka' 'expect' 'iproute2' 'python-yaml' 'swtpm' 'tpm2-abrmd' 'xxd')
optdepends=('tpm2-abrmd: user space resource manager')
options=('debug' '!lto')
source=("$url/releases/download/$pkgver/$pkgname-$pkgver.tar.gz"{,.asc})
sha512sums=('224a5ea3448a877362abb35ac06b115c559c09b44b30d74c8326211be66d24e0e130c285b1e285be1842e7203ab488629b0f4e451cbd782c83ed72023d146675'
            'SKIP')
validpgpkeys=('5B482B8E3E19DA7C978E1D016DE2E9078E1F50C1'  # William Roberts (Bill Roberts) <william.c.roberts@intel.com>
              '6313E6DC41AAFC315A8760A414986F6944B1F72B') # Desai, Imran (idesai-github-gpg) <imran.desai@intel.com>

build() {
	cd "$pkgname-$pkgver"
	./configure --prefix=/usr $( ((CHECKFUNC)) && echo --enable-unit)
	make
}

check() {
	cd "$pkgname-$pkgver"
	make check
}

package() {
	cd "$pkgname-$pkgver"
	make DESTDIR="$pkgdir" install
	install -Dm644 docs/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
